package org.nfIt.controller;


import org.nfIt.service.FileUploadService;
import org.nfIt.vo.common.Result;
import org.nfIt.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * ClossName:FileUploadController
 * Pakage:org.nfIt.controller
 * Description
 *
 * minio上传controller
 *
 * @Author L
 * @Create 2024/6/22 21:43
 * @Version 2023.1.3
 */
@RestController
@RequestMapping("/admin/system")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    /**
     * minio文件上传
     * <input type="file" name="file" />
     * @param file 路径
     */
    @PostMapping(value = "/fileUpload")
    public Result<String> fileUploadService(@RequestParam(value = "file") MultipartFile file) {

        //获取service的方法上传，返回minio路径
        String fileUrl = fileUploadService.fileUpload(file) ;
        return Result.build(fileUrl , ResultCodeEnum.SUCCESS) ;
    }

}
